package ferp.android.widgets.buttons;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.Button;
import ferp.android.GUI;

/**
 * User: igorgok
 * Date: 1/14/14 8:50 AM
 */
public class ProfileSelector extends Button
{
  public ProfileSelector(Context context)
  {
    this(context, null, 0);
  }

  public ProfileSelector(Context context, AttributeSet attrs)
  {
    this(context, attrs, 0);
  }

  public ProfileSelector(Context context, AttributeSet attrs, int defStyle)
  {
    super(context, attrs, defStyle);

    setGravity(Gravity.CENTER);
    setTypeface(GUI.Font.BOLD);
    setText("", BufferType.SPANNABLE);
  }

  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
  {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    // try to set the text size
    if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY)
    {
      if (GUI.FitText.byWeight(this, this))
      {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        //Log.debug(Log.TAG, "PS - size " + getMeasuredWidth() + "x" + getMeasuredHeight() + ", th " + getTextSize());
      }

      //Log.debug(Log.TAG, "PS - ratio " + ((float)getMeasuredWidth() / (float)getMeasuredHeight()));
    }
  }
}
